<template>
  <div class="container">
    <!-- 内容展示区域 -->
    <div class="screen" ref="screen">
      <div class="top"><Top /></div>
      <div class="bottom">
        <div class="left">
          <Tourist class="Tourist"></Tourist>
          <Sex class="Sex"></Sex>
          <Age class="Age"></Age>
        </div>
        <div class="center">中间</div>
        <div class="right">右边</div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { onMounted, ref } from "vue";
//顶部组件
import Top from "./part/top/index.vue";
//左侧组件
import Tourist from "./part/tourist/index.vue";
import Sex from "./part/sex/index.vue";
import Age from "./part/age/index.vue";

//屏幕适配
let screen = ref();

//计算大屏缩放比例
const getScale = (w = 1920, h = 1080) => {
  const ww = window.innerWidth / w;
  const wh = window.innerHeight / h;
  return ww < wh ? ww : wh;
};

onMounted(() => {
  //屏幕适配
  screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`;
});

//监听窗口变化
window.onresize = () => {
  screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`;
};
</script>

<style scoped lang="scss">
.container {
  width: 100vw;
  height: 100vh;
  background: url(./images/bg.png) no-repeat;
  background-size: cover;

  .screen {
    //用于适配
    position: fixed;
    transform-origin: left top;
    left: 50%;
    top: 50%;
    width: 1920px; //根据原型图设计
    height: 1080px; //根据原型图设计
    .top {
      width: 100%;
      height: 40px;
    }
    .bottom {
      display: flex;
      .left {
        margin-left: 20px;
        flex: 1;
        height: 1040px; //原型图高度-顶部高度
        display: flex;
        flex-direction: column;
        .Tourist {
          flex: 1.2;
        }
        .Sex {
          flex: 1;
        }
        .Age {
          flex: 1;
        }
      }
      .center {
        flex: 2;
        height: 1040px; //原型图高度-顶部高度
      }
      .right {
        margin-right: 20px;
        flex: 1;
        height: 1040px; //原型图高度-顶部高度
      }
    }
  }
}
</style>
